<!DOCTYPE HTML>
<html>
<head>
    <title>編輯</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <script src="/scripts/boot.js" type="text/javascript"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <link rel="stylesheet" href="/editor/common.css">
    <script src="/scripts/miniui/miniui.js"></script>
</head>
<body>
<div id="form1" style="padding-left: 60px">
    <span style="width:60px;display:inline-block;">价格：</span>
    <input id="price" name="price" class="mini-textbox" required="true" type="number" style="width:155px;" value="<%= result.attributes.price%>"/>
    <br/><br/>
    <span style="width:60px;display:inline-block;">积分：</span>
    <input id="score" name="score" class="mini-textbox" required="true"  type="number" style="width:155px;" value="<%= result.attributes.score%>"/>
    <br/><br/>
    <span style="width:60px;display:inline-block;">运费：</span>
    <input id="freight" name="freight" class="mini-textbox" required="true" type="number" style="width:155px;" value="<%= result.attributes.freight%>" />
    <br/><br/>
    <span style="width:60px;display:inline-block;">购买数量：</span>
    <input id="count" name="count" class="mini-textbox" required="true" type="number" style="width:155px;" value="<%= result.attributes.count%>" />
    <br/><br/>
    <span style="width:60px;display:inline-block;">赠送积分：</span>
    <input id="presentScore" name="presentScore" class="mini-textbox" required="true" type="number" style="width:155px;" value="<%= result.attributes.presentScore%>" />
    <br/><br/>
    <span style="width:60px;display:inline-block;">上一级分成钱：</span>
    <input id="superiorMoney" name="superiorMoney" class="mini-textbox" required="true" type="number" style="width:155px;" value="<%= result.attributes.superiorMoney%>" />
    <br/><br/>
    <span style="width:60px;display:inline-block;">上二级分成钱：</span>
    <input id="superiorSuperiorMoney" name="superiorSuperiorMoney" class="mini-textbox" required="true" type="number" style="width:155px;" value="<%= result.attributes.superiorSuperiorMoney%>" />
    <br/><br/>
    <span style="width:60px;display:inline-block;">上二级祖辈分成钱：</span>
    <input id="ancestorsMoney" name="ancestorsMoney" class="mini-textbox" required="true" type="number" style="width:155px;" value="<%= result.attributes.ancestorsMoney%>" />
    <br/><br/>
    <span style="width:60px;display:inline-block;">上一级分成积分比例：</span>
    <input id="superiorScore" name="superiorScore" class="mini-textbox" required="true" type="number" style="width:155px;" value="<%= result.attributes.superiorScore%>" />
    <br/><br/>
    <span style="width:60px;display:inline-block;">上二级分成积分比例：</span>
    <input id="superiorSuperiorScore" name="superiorSuperiorScore" class="mini-textbox" required="true" type="number" style="width:155px;" value="<%= result.attributes.superiorSuperiorScore%>" />
    <br/><br/>
    <span style="width:60px;display:inline-block;">上二级祖辈分成积分比例：</span>
    <input id="ancestorsScore" name="ancestorsScore" class="mini-textbox" required="true" type="number" style="width:155px;" value="<%= result.attributes.ancestorsScore%>" />
</div>
<div style="margin: 30px 0;text-align: center">
    <a class="mini-button " iconCls="icon-ok" onclick="editScoreGoodShop()">确定</a>
    <a class="mini-button" iconCls="icon-cancel" onclick="onCancel">取消</a>
</div>
</body>
<script>
  var objectId = '<%=result.id%>';
  mini.parse();
  function editScoreGoodShop() {
    var form = new mini.Form("#form1");
    form.validate();
    if (form.isValid() == false) return;
    var price = mini.get("price").getValue();
    var score = mini.get("score").getValue();
    var freight = mini.get("freight").getValue();
    var count = mini.get("count").getValue();
    var presentScore = mini.get("presentScore").getValue();
    var superiorMoney = mini.get("superiorMoney").getValue();
    var superiorSuperiorMoney = mini.get("superiorSuperiorMoney").getValue();
    var ancestorsMoney = mini.get("ancestorsMoney").getValue();
    var superiorScore = mini.get("superiorScore").getValue();
    var superiorSuperiorScore = mini.get("superiorSuperiorScore").getValue();
    var ancestorsScore = mini.get("ancestorsScore").getValue();
    $.ajax({
      type: "POST",
      url: "/getdata/editTECGoodsShop",
      data: {
        objectId,
        price,
        score,
        freight,
        count,
        presentScore,
        superiorMoney,
        superiorSuperiorMoney,
        ancestorsMoney,
        superiorScore,
        superiorSuperiorScore,
        ancestorsScore
      },
      success: function (result) {
        if(result =="1"){
          alert("更新成功");
          CloseWindow("save");
        }else{
          alert("更新失敗")
          CloseWindow("save");
        }

      }
    })
  }
  //    关闭窗口
  function CloseWindow(action) {
    if (action == "close" && form.isChanged()) {
      if (confirm("数据被修改了，是否先保存？")) {
        return false;
      }
    }
    if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
    else window.close();
  }

  function onCancel(e) {
    CloseWindow("cancel");
  }
</script>
</html>